/******************************************************
* Script for displaying popup help box
* Written by http://hamang.net
******************************************************/

var NN=(navigator.appName == "Netscape" && 
          navigator.userAgent.indexOf("Mozilla") != -1 && 
          parseInt(navigator.appVersion) >= 4); 
var IE=(navigator.userAgent.indexOf("MSIE") != -1 && 
          navigator.userAgent.indexOf("Mozilla") != -1 && 
          parseInt(navigator.appVersion) >= 4); 


          
if (NN) 
   document.captureEvents(Event.MOUSEMOVE); 
var mouseX, mouseY, maxDocumentWidth;
document.onmousemove = mouseCoords;

var arrHiddenSelects = new Array();
function mouseCoords(e) 
{ 
    if (NN) 
    { 
        mouseX = e.pageX - 50; 
        mouseY = e.pageY + 7; 
     } 
     if (IE) { 
		if( document.body ) {
			maxDocumentWidth = document.body.clientWidth - 140;
			//maxDocumentHeight = document.body.clientHeight - 80;
			mouseX = document.body.scrollLeft + event.clientX; 
			mouseY = document.body.scrollTop + event.clientY + 7; 
		}
     } 
}

function showHelpBox(par_object, par_textObject, par_helpText)
{     
    var objTd = eval("" + par_textObject);
    var objPointerElement = document.getElementById("helpPointer");
    
    if( objTd ) {
		objTd.innerHTML = "" + par_helpText;// + "\nmousex:" + (mouseX - 24) + ", " + "mouseY:" +  (mouseY + 3) + "\ndocument.width:" + document.body.clientWidth + "\ndocument.height" + document.body.clientHeight;
		
		if (NN)
		{        
			document.layers[par_object].above;
			document.layers[par_object].left = mouseX - 10;
			document.layers[par_object].top = mouseY + 13; 
			document.layers[par_object].visibility = 'show';
		} 
		if (IE) 
		{ 
			document.all[par_object].style.above;
			//To prevent the box exiting the screen

			if (mouseX > maxDocumentWidth)
				document.all[par_object].style.pixelLeft = maxDocumentWidth - 24;
			else
				document.all[par_object].style.pixelLeft = mouseX - 24;
	            
			document.all[par_object].style.pixelTop = mouseY + 3;
			document.all[par_object].style.visibility = 'visible';
	        
			//objTd.innerText += "\n" + objPointerElement.id;
			if (objPointerElement != null)
			{
				var objPointer = (objPointerElement.id)
				document.all[objPointer].style.above;
    			//To prevent the pointer exiting the screen
				if (mouseX > (maxDocumentWidth + 125))
					document.all[objPointer].style.pixelLeft = maxDocumentWidth + 100;
				else
					document.all[objPointer].style.pixelLeft = mouseX - 25;
	        
				//document.all[objPointer].style.pixelLeft = mouseX - 25;
    			document.all[objPointer].style.pixelTop = mouseY + 5;
				document.all[objPointer].style.visibility = 'visible';
			}
			
			var debugString = "";
			var selects = document.getElementsByTagName("select");
			debugString += "\n" + selects.length;
			debugString += "\nmouseCoords: x=" + mouseX + ", y=" + mouseY ;
			
			debugString += "\nmouseBox: x=" + objTd.offsetLeft + ", y=" + objTd.offsetTop +
							", width=" + objTd.offsetWidth + ", height=" + objTd.offsetHeight  ;
						
			debugString += "\nSource: " + window.event.srcElement.nodeName;
			//objTd.innerText += "\n" + debugString;
			for (var i = 0; i < selects.length; i++)
			{					
				var theSelect = selects[i];
				//debugString += "\nx: " + theSelect.uniqueID;					
				//debugString += "\n\nselect " + i + ": x=" + theSelect.offsetLeft + ", y=" + theSelect.offsetTop +
				//			", width=" + theSelect.offsetWidth + ", height=" + theSelect.offsetHeight  ;
				if (theSelect.offsetLeft > mouseX - 80 &&  theSelect.offsetLeft < mouseX + objTd.offsetWidth && 
					theSelect.offsetTop > mouseY - 25 && theSelect.offsetTop < mouseY + objTd.offsetHeight + 35 && 
					window.event.srcElement.uniqueID != theSelect.uniqueID )
				{
					theSelect.style.visibility = "hidden";
				}
			}
		}    
    }
}

function hideHelpBox(par_object)
{
    if (NN)
        document.layers[par_object].visibility = 'hide';
    if (IE)
    {
        
        document.all[par_object].style.visibility = 'hidden';
        
        var objPointerElement = document.getElementById("helpPointer");
        if (objPointerElement != null)
        {
            var objPointer = (objPointerElement.id)
            document.all[objPointer].style.visibility = 'hidden';
        }
        
        //Showing the hidden selects again
        
        var blnShowSelects = true;
        var ie5menu = document.getElementById("ie5menu");
        if (ie5menu != null && "" + ie5menu != "undefined")
        {
			if (ie5menu.style.visibility == "visible")
			{
				blnShowSelects = false;
			}
        }
        
        if (blnShowSelects)
        {
			var selects = document.getElementsByTagName("select");
			for (var i = 0; i < selects.length; i++)
			{					
				var theSelect = selects[i];
				if (theSelect.style.visibility == "hidden")
				{
					theSelect.style.visibility = "visible";			
				}
			}
		}
    }
}